<?php
getHeader();
?>
<div id="content">
<div class="tabs headTabs"><span>文件修改</span></div>
<div class="dataList"><?php
if (!isset($_GET['action']))
{
	?> <span>请在"我的信息"页内指定一个操作.</span> <?php
}
else
{
	$file = thisFile::getFileByFid((int)$_GET['fid']);
	if ($file->owner != $_SESSION['uid'])
	{
		?> <span>你无权对该文件进行操作.</span> <?php
	}
	else if ($_GET['action'] == 'mod')
	{
		if (isset($_POST['fileName']))
		{
			$file->pureName = $_POST['fileName'];
			$file->status = $_POST['fileStatus'];
			if ($file->update())
			{
				?> <span>修改成功.</span> <?php
			}
		}
		else
		{
			?>
<ul>
	<form action='?p=editFile&action=mod&fid=<?php echo $file->fid; ?>'
		method="post">
	<li>文件名: <input type="text" name="fileName"
		value="<?php echo $file->pureName; ?>">.<?php echo $file->extension; ?></li>
	<li>共享情况: <select name="fileStatus">
		<option value="Shared"
		<?php if ($file->status == "Shared") echo "selected='selected'";?>>已共享</option>
		<option value="Unshared"
		<?php if ($file->status != "Shared") echo "selected='selected'";?>>未共享</option>
	</select></li>
	<li><input type="submit" value="修改" class="button" /></li>
	</form>
</ul>
		<?php
		}
	}
	else if ($_GET['action'] == 'del')
	{
		if (isset($_POST['fileDel']) && $_POST['fileDel'] == "yes")
		{
			if ($file->del())
			{
				?> <span>删除成功.</span> <?php
			}
		}
		else
		{
			?> <span>
<ul>
	<form action='?p=editFile&action=del&fid=<?php echo $file->fid; ?>'
		method="post">
	<li>你确定要删除吗? <input type="hidden" name="fileDel" value="yes"></li>
	<li><input type="submit" value="是的" class="button"
		style="margin: 0 10px 0 0;" /><a href='?p=viewUser' class="button">不是</a></li>
	</form>
</ul>
</span> <?php
		}
	}
}
?></div>
</div>
<?php
getPanel();
getFooter();
?>